package com.mdd.admin.controller.yylq;

import com.mdd.admin.aop.Log;
import com.mdd.admin.service.yylq.ITAppCorporateFinanceService;
import com.mdd.admin.validate.commons.IdValidate;
import com.mdd.admin.validate.commons.PageValidate;
import com.mdd.admin.validate.yylq.TAppCorporateFinanceCreateValidate;
import com.mdd.admin.validate.yylq.TAppCorporateFinanceSearchValidate;
import com.mdd.admin.validate.yylq.TAppCorporateFinanceUpdateValidate;
import com.mdd.admin.vo.yylq.TAppCorporateFinanceDetailVo;
import com.mdd.admin.vo.yylq.TAppCorporateFinanceListedVo;
import com.mdd.common.core.AjaxResult;
import com.mdd.common.core.PageResult;
import com.mdd.common.validator.annotation.IDMust;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;

import javax.annotation.Resource;

@RestController
@RequestMapping("/adminapi/yylq/finance")
@Api(tags = "羊羊领企---企业融资管理")
public class TAppCorporateFinanceController {

    @Resource
    ITAppCorporateFinanceService iTAppCorporateFinanceService;

    @GetMapping("/list")
    @ApiOperation(value="企业融资列表")
    public AjaxResult<PageResult<TAppCorporateFinanceListedVo>> list(@Validated PageValidate pageValidate,
                                                                     @Validated TAppCorporateFinanceSearchValidate searchValidate) {
        PageResult<TAppCorporateFinanceListedVo> list = iTAppCorporateFinanceService.list(pageValidate, searchValidate);
        return AjaxResult.success(list);
    }

    @GetMapping("/detail")
    @ApiOperation(value="企业融资详情")
    public AjaxResult<TAppCorporateFinanceDetailVo> detail(@Validated @IDMust() @RequestParam("id") Integer id) {
        TAppCorporateFinanceDetailVo detail = iTAppCorporateFinanceService.detail(id);
        return AjaxResult.success(detail);
    }

    @Log(title = "企业融资新增")
    @PostMapping("/add")
    @ApiOperation(value="企业融资新增")
    public AjaxResult<Object> add(@Validated @RequestBody TAppCorporateFinanceCreateValidate createValidate) {
        iTAppCorporateFinanceService.add(createValidate);
        return AjaxResult.success();
    }

    @Log(title = "企业融资编辑")
    @PostMapping("/edit")
    @ApiOperation(value="企业融资编辑")
    public AjaxResult<Object> edit(@Validated @RequestBody TAppCorporateFinanceUpdateValidate updateValidate) {
        iTAppCorporateFinanceService.edit(updateValidate);
        return AjaxResult.success();
    }

    @Log(title = "企业融资删除")
    @PostMapping("/del")
    @ApiOperation(value="企业融资删除")
    public AjaxResult<Object> del(@Validated @RequestBody IdValidate idValidate) {
        iTAppCorporateFinanceService.del(idValidate.getId());
        return AjaxResult.success();
    }

}
